﻿//
// Copyright (c) 2024 BPer
//

#include <bperutil/buffer/BPerAudioPlayBuffer.h>



BPerAudioPlayBuffer::BPerAudioPlayBuffer() {
	resetIndex();
    m_cache_num = 50;
	m_bufLen=0;

}

void BPerAudioPlayBuffer::reset() {
	resetIndex();
}

BPerAudioPlayBuffer::~BPerAudioPlayBuffer(void) {

}

void BPerAudioPlayBuffer::putAudio(BPerFrame* pframe) {
	if(m_bufLen==0){
		m_bufLen = pframe->nb;
		initFrames(m_cache_num,pframe->nb);

	}

	putFrame(pframe);
}

void BPerAudioPlayBuffer::getAudio(BPerFrame* pframe) {

	getFrame(pframe);
}

uint8_t* BPerAudioPlayBuffer::getAudios(BPerFrame* pframe) {
	if (size() < 1)
		return NULL;
	return getFrameRef(pframe);

}
int32_t BPerAudioPlayBuffer::getFrameTimestamp(int64_t *ptimestamp) {

	BPerFrame* f=getCurFrameRef();
	if(f) *ptimestamp=f->pts;
	return BPer_Ok;
}
int64_t BPerAudioPlayBuffer::getNextTimestamp(){
	return getNextFrameTimestamp();
}


